package sctu.edu.java.year2016.team06.lvjiafu.day20160522.chapter4_3;

/**
 * Created by lvjiafu on 2016/5/22.
 * 编写Java程序，使用While循环语句计算出1+1/2！+1/3！...1/20!之和
 */
public class chapter4_3 {
    public static void main(String[] args){
        double sum=0,i=1,s=1;
        while (i<20){
            sum=sum+s;
            i++;
            s=s*(1.0/i);
        }
        System.out.println("1+1/2!+1/3!..+1/20!之和为："+sum);
    }
}